home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / Source / MSG Demo 1.4.source Folder / Demo ƒ / Fades reversed ƒ / Four centered fade reversed.c < prev    next >
Text File  |  1994-04-15  |  3KB  |  103 lines

  1. /**********************************************************************\
  2.  
  3. File:        Four centered fade reversed.c
  4.  
  5. Purpose:    Graphic effect to fade main window to solid pattern.
  6.             See comments below for more description.
  7.  
  8. This program is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 2 of the License, or
  11. (at your option) any later version.
  12.  
  13. This program is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. GNU General Public License for more details.
  17.  
  18. You should have received a copy of the GNU General Public License
  19. along with this program in a file named "GNU General Public License".
  20. If not, write to the Free Software Foundation, 675 Mass Ave,
  21. Cambridge, MA 02139, USA.
  22.  
  23. \**********************************************************************/
  24.  
  25. #include "timing.h"
  26.  
  27. #define CorrectTime 6
  28. #define theWindowHeight (boundsRect.bottom-boundsRect.top)
  29. #define theWindowWidth (boundsRect.right-boundsRect.left)
  30.  
  31. pascal short FourCenteredFadeReversed(Rect boundsRect, Pattern *thePattern);
  32.  
  33. /* Really, this only uses one region and one CopyBits per round.  Regions don't
  34.    have to be continuous.  On each axis, on each side of the center of the screen,
  35.    there are two parts of the region which move from the corners to the center. */
  36.    
  37. pascal short FourCenteredFadeReversed(Rect boundsRect, Pattern *thePattern)
  38. {
  39.     RgnHandle    curregion, boundsRgn, sectrgn;
  40.     int            cx,cy,lastx,lasty;
  41.     int            BlockSize, VBlockSize;
  42.     
  43.     cx = boundsRect.left + theWindowWidth / 2;
  44.     cy = boundsRect.top + theWindowHeight / 2;
  45.     BlockSize=theWindowWidth/50;
  46.     VBlockSize=theWindowHeight/50;
  47.  
  48.     boundsRgn=NewRgn();
  49.     RectRgn(boundsRgn, &boundsRect);
  50.     sectrgn=NewRgn();
  51.     
  52.     curregion=NewRgn();
  53.     
  54.     lasty=theWindowHeight/2;
  55.     lastx=theWindowWidth/2;
  56.     do
  57.     {
  58.         StartTiming();
  59.         SetEmptyRgn(curregion);
  60.         MoveTo(cx,cy);
  61.         OpenRgn();              /* much much faster than 8 regions/CopyBits */
  62.             LineTo(cx-lastx,boundsRect.top);
  63.             Line(-BlockSize,0);
  64.             LineTo(cx+lastx+BlockSize,boundsRect.bottom);
  65.             Line(-BlockSize,0);
  66.             LineTo(cx,cy);
  67.             
  68.             LineTo(cx+lastx,boundsRect.top);
  69.             Line(BlockSize,0);
  70.             LineTo(cx-lastx-BlockSize,boundsRect.bottom);
  71.             Line(BlockSize,0);
  72.             LineTo(cx,cy);
  73.             
  74.             LineTo(boundsRect.right,cy-lasty);
  75.             Line(0,-VBlockSize);
  76.             LineTo(boundsRect.left,cy+lasty+VBlockSize);
  77.             Line(0,-VBlockSize);
  78.             LineTo(cx,cy);
  79.             
  80.             LineTo(boundsRect.right,cy+lasty);
  81.             Line(0,VBlockSize);
  82.             LineTo(boundsRect.left,cy-lasty-VBlockSize);
  83.             Line(0,VBlockSize);
  84.             LineTo(cx,cy);
  85.         CloseRgn(curregion);
  86.  
  87.         SectRgn(curregion, boundsRgn, sectrgn);
  88.         FillRgn(sectrgn, *thePattern);
  89.         lastx-=BlockSize;
  90.         lasty-=VBlockSize;
  91.         TimeCorrection(CorrectTime);
  92.     }
  93.     while (lastx>boundsRect.left);
  94.  
  95.     FillRect(&boundsRect, *thePattern);        /* in case we miss a few pixels */
  96.     
  97.     DisposeRgn(curregion);
  98.     DisposeRgn(boundsRgn);
  99.     DisposeRgn(sectrgn);
  100.     
  101.     return 0;
  102. }
  103.